In [7]:
import scipy.io as sio
import numpy as np
import matplotlib.pyplot as plt
from skimage import data
%matplotlib inline

In [2]:
mat_contents = sio.loadmat('positive_instances.mat')
flattened_face_regions = [(r[0][0], r[1][0]) for r in mat_contents['positiveInstances'][0]]

# Remove absolute path
face_regions = [(x[0].replace('/Users/vt/Code/Personal/hot-car-data-collection/', ''), x[1]) for x in flattened_face_regions]
np.save('face_regions.npy', np.array(face_regions, dtype=object))

Try loading saved file to see if it works


In [13]:
saved_face_regions = np.load('face_regions.npy')
row = saved_face_regions[0]
image = data.imread(row[0])
plt.imshow(image)


Out[13]:
<matplotlib.image.AxesImage at 0x114a48978>

Show the face region of intee


In [14]:
y = row[1][0]
x = row[1][1]
height = row[1][2]
width = row[1][3]
plt.imshow(image[x:x+width,y:y+height])


Out[14]:
<matplotlib.image.AxesImage at 0x114b7af28>

In [ ]: